<template>
  <el-aside width="25%">
    <div class="menus" id="menus">
      <div class="create-new-link" @click="createLinkModalShow">
        <i class="el-icon-plus"></i>
        <span slot="title">创建连接</span>
      </div>
      <el-menu class="el-menu-vertical-demo" :unique-opened="uniqueOpened">
        <Link v-for="(linkInfo,index) in linkInfos" :key="index" :index="index" :linkInfo="linkInfo"/>
      </el-menu>
    </div>

  </el-aside>
</template>

<script>
  import Link from "./link/Link";
  import {mapGetters} from "vuex";

  export default {
    name: "LinkPanel",
    components: {Link},
    computed:{
    ...mapGetters(["linkInfos"])
    },data(){
      return {
        uniqueOpened:true
      }
    },
    methods: {
      createLinkModalShow() {
        this.$store.dispatch("createLinkModalShow", true);
      }
    },watch: {
      linkInfos: {
        deep: true, //深度监视
        handler: function (newValue, oldValue) {

        }
      }
    }
  }
</script>

<style scoped>
  .create-new-link {
    text-align: center;
    background: rgb(238, 241, 246);
    height: 50px;
    line-height:45px;
    cursor:pointer
  }

  .menus {
    overflow-y: auto;
    height: 760px;
  }
</style>
